var GownFullMenu = GFMenu.extend({
	ime: null,
	imnode: null,
	imnode_mini: null,
	constructor: function(ime)
	{
		this.ime = ime;
		var head = new GFMenuNode($GFS('Menu'));
		var x = this;

		this.imnode = new GFMenuNode($GFS('Switch Input Method'));
		this.imnode_mini = new GFMenuNode($GFS('Switch Input Method'));
		this.imnode_mini.SetItem(4,$GFS('More'), function() { return x.ShowIMMenu(false); });

		head.SetItem(0,$GFS('Toggle on/off IME'), function() { return x.ToggleIME(); });
		head.SetItem(1,$GFS('Switch Input Method'), this.imnode);
		head.SetItem(2,'Input Method 1',function() { return true; });
		head.SetItem(3,'Input Method 2',function() { return true; });
		head.SetItem(4,'Input Method 3',function() { return true; });
		head.SetItem(5,'&nbsp;',null);
		head.SetItem(6,$GFS('Report a bug'), function() {
			x.ime.browserwin.OpenURL('http://ajaxime.com/bugzilla/enter_bug.cgi');
			x.ime.browserwin.SetTitle($GFS('GownFull Bugzilla'));
			return true;
		});
		head.SetItem(7,$GFS('GownFull Developers Blog'), function() {
			x.ime.browserwin.OpenURL('http://gownfull.blogspot.com/');
			x.ime.browserwin.SetTitle($GFS('GownFull Developers Blog'));
			return true; 
		});
		head.SetItem(8,$GFS('GownFull Google Group'), function() {
			x.ime.browserwin.OpenURL('http://groups.google.com/group/gownfull/');
			x.ime.browserwin.SetTitle($GFS('GownFull Google Group'));
			return true;
		});
		head.SetItem(9,$GFS('Module'), this.ime.modman.GetMenuNode());

		this.base(head);
	},
	ShowMenu: function(nomove) {},
	HideMenu: function() {},
	PopupCustomMenu: function(node,dropbox) {},
	ShowIMMenu: function(mini) {},
	UpdateIM: function()
	{
		var i;
		var len = this.ime.GetInputMethodCount();
		var x = this;
		var fun1 = function(pos) { return x.SwitchIM(pos); };
		var fun2 = function(pos) { return x.SwitchIM(pos-2); };
		var n;

		for(i=0;i<len;i++) this.imnode.SetItem(i,this.ime.GetInputMethodName(i), fun1);

		n = (len < 4) ? len : 4;
		for(i=0;i<n;i++) this.imnode_mini.SetItem(i,this.ime.GetInputMethodName(i), fun1);
		n = (len < 3) ? len : 3;
		for(i=0;i<n;i++) this.head.SetItem(i+2,$GFS('Switch to ') + this.ime.GetInputMethodName(i), fun2);
	},
	SwitchIM: function(pos)
	{
		this.ime.SelectInputMethod(pos);
		return true;
	},
	UpdateIMNode: function(im)
	{
		var node = im.GetMenuNode();

		if(node == null) {
			this.head.SetItem(5,'&nbsp;',null);
		}
		else {
			this.head.SetItem(5,im.IMName() + $GFS('Input Method Settings'),node);
		}
	},
	ToggleIME: function()
	{	
		this.ime.ToggleIME(!this.ime.state.available);
		return true;
	}
});

